import request from '@/utils/request'
import { apiVersion } from '@/config'

/**
 * 列表
 * @param {} data 
 */
export function getGameTasks(data) {
  return request({
    url: `/admin/${apiVersion}/game/task`,
    method: 'get',
    data
  })
}

/**
 * 全部
 * @param {} data 
 */
 export function getAllGameTasks(data) {
  return request({
    url: `/admin/${apiVersion}/game/task/all`,
    method: 'get',
    data
  })
}
/**
 * 添加
 * @param {} data 
 */
export function addGameTask(data) {
  return request({
    url: `/admin/${apiVersion}/game/task`,
    method: 'post',
    data: data
  })
}
/**
 * 删除
 * @param {} data 
 */
export function delGameTask(data) {
  return request({
    url: `/admin/${apiVersion}/game/task/${data.id}`,
    method: 'delete',
    data
  })
}
/**
 * 更新
 * @param {} data 
 */
export function putGameTask(data) {
  return request({
    url: `/admin/${apiVersion}/game/task`,
    method: 'put',
    data: data
  })
}
/**
 * 取得详情
 * @param {*} data 
 */
export function getGameTaskDetail(data) {
  return request({
    url: `/admin/${apiVersion}/game/task/${data.id}`,
    noLoadding: true,
    method: 'get',
  })
}
// 根据来源查询
export function getGameTaskBySource(data) {
  return request({
      url: `/admin/${apiVersion}/game/task/bySource`,
      method: 'get',
      data
  })
}
/**
 * 版本列表
 * @param {} data 
 */
 export function getGameTaskVersions(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion`,
    method: 'get',
    data
  })
}
/**
 * 获取监控分页列表(非停止状态)
 * @param {} data 
 */
 export function getGameTaskVersionsMonitor(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion/monitor`,
    method: 'get',
    data
  })
}
/**
 * 版本添加
 * @param {} data 
 */
export function addGameTaskVersion(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion`,
    method: 'post',
    data: data
  })
}
/**
 * 版本删除
 * @param {} data 
 */
export function delGameTaskVersion(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion/${data.id}`,
    method: 'delete',
    data
  })
}
/**
 * 版本更新
 * @param {} data 
 */
export function putGameTaskVersion(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion`,
    method: 'put',
    data: data
  })
}
/**
 * 取取版本详情
 * @param {*} data 
 */
export function getGameTaskVersionDetail(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion/${data.id}`,
    noLoadding: true,
    method: 'get',
  })
}

export function getAllGameTaskVersions(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion/all`,
    noLoadding: true,
    method: 'get',
    data: data
  })
}
/**
 * 获取podname
 * @param {*} data 
 */
export function getGameTaskVersionPodName(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion/${data.id}/podName`,
    noLoadding: true,
    method: 'get',
  })
}



/**
 * 启动
 * @param {} data 
 */
 export function startGameTaskVersion(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion/${data.id}/start`,
    method: 'put',
    data
  })
}
/**
 * 停止
 * @param {} data 
 */
 export function stopGameTaskVersion(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion/${data.id}/stop`,
    method: 'put',
    data
  })
}


/**
 * 获取指标或图示数据详情
 * @param {*} data 
 */
 export function metricData(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion/${data.id}/metric/data`,
    noLoadding: true,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    method: 'get',
    data
  })
}
/**
 * 获取指标或图示名称
 * @param {*} data 
 */
export function metricKeys(data) {
  return request({
    url: `/admin/${apiVersion}/game/taskVersion/${data.id}/metric/keys`,
    noLoadding: true,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    method: 'get',
    data
  })
}